/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ArrayIterator;

import java.util.ArrayList;
import java.util.Iterator;

public class Test2 {
    public static void main(String[] args) {
        ArrayList l = new ArrayList();
        l.add("a");
        l.add("b");
        l.add("c");
        l.add("d");
        l.add("e");
        l.add("f");

        ArrayList l2 = new ArrayList();
        l2.add("g");
        l2.add("h");


        Iterator i = l.iterator();
        long a=System.currentTimeMillis();
        while(i.hasNext()) {
                System.out.print(i.next().toString());
        }
        System.out.println("执行耗时 : "+(System.currentTimeMillis()-a) * 1000000000f+" 秒 ");
        System.out.println();

        long b=System.currentTimeMillis();
        for(Object o : l) {
                System.out.print(o.toString());
        }
        System.out.println("执行耗时 : "+(System.currentTimeMillis()-b) * 1000000000f+" 秒 ");
        System.out.println();

        long c=System.currentTimeMillis();
        for(int j=0;j<l.size();j++) {
                System.out.print(l.get(j).toString());
        }
        System.out.println("执行耗时 : "+(System.currentTimeMillis()-c) * 1000000000f+" 秒 ");
        System.out.println();
    }
}
